#pragma once

namespace rt
{
	struct Ray;
	struct Ray4;
	struct Ray4_SingleOrigin;
	struct IntersectionData;

	struct Algeb
	{
		void* operator new[] (size_t size)
		{
			void * p = _aligned_malloc(size, 16);
			if (p == 0) LOG("ACHTUNG!!! OUT OF MEMORY!!!");
			return p;
		}
		void operator delete[] (void *p)
		{
			_aligned_free(p);
		}

		inline float value(const XMVECTOR & point) const;
		XMVECTOR normal(const XMVECTOR & point) const;
	};

	void IntersectAlgebs_All_4RaysSingleOrigin(const Algeb * blobs, int num, const Ray4_SingleOrigin & rays, XMVECTOR & intersIndex, XMVECTOR & depth);
	void IntersectAlgebs_All_4Rays(const Algeb * blobs, int num, const Ray4 & rays, XMVECTOR & intersIndex, XMVECTOR & depth, XMVECTOR & intersType);

	void GetAlgebIntersectionData(const Algeb & blob, XMVECTOR intersPoint, IntersectionData & data);

}
